<?php

namespace app\seller\controller;

use app\common\controller\Seller;
use app\common\model\User;
use think\Db;

/**
 * 控制台
 *
 * @icon fa fa-dashboard
 * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
 */
class Dashboard extends Seller
{

    /**
     * 查看
     */
    public function index()
    {
	    $totaluser = Db::name('user')->count();
        $seventtime = \fast\Date::unixtime('day', -7);
        $paylist = $createlist = [];
        for ($i = 0; $i < 7; $i++)
        {
            $day = date("Y-m-d", $seventtime + ($i * 86400));
            $createlist[$day] = mt_rand(20, 200);
            $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
        }
        $hooks = config('addons.hooks');
        $uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
        $this->view->assign([
            'totaluser'        => $totaluser,
            'totalviews'       => 219390,
            'totalorder'       => 32143,
            'totalorderamount' => 174800,
            'todayuserlogin'   => 321,
            'todayusersignup'  => 430,
            'todayorder'       => 2324,
            'unsettleorder'    => 132,
            'sevendnu'         => '80%',
            'sevendau'         => '32%',
            'paylist'          => $paylist,
            'createlist'       => $createlist,
            'uploadmode'       => $uploadmode
        ]);

        return $this->view->fetch();
    }
	
	/**
	 * 查看
	 */
	public function menu()
	{
		$totaluser = Db::name('user')->count();
		$seventtime = \fast\Date::unixtime('day', -7);
		$paylist = $createlist = [];
		for ($i = 0; $i < 7; $i++)
		{
			$day = date("Y-m-d", $seventtime + ($i * 86400));
			$createlist[$day] = mt_rand(20, 200);
			$paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
		}
		$hooks = config('addons.hooks');
		$uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
		$this->view->assign([
			'totaluser'        => $totaluser,
			'totalviews'       => 219390,
			'totalorder'       => 32143,
			'totalorderamount' => 174800,
			'todayuserlogin'   => 321,
			'todayusersignup'  => 430,
			'todayorder'       => 2324,
			'unsettleorder'    => 132,
			'sevendnu'         => '80%',
			'sevendau'         => '32%',
			'paylist'          => $paylist,
			'createlist'       => $createlist,
			'uploadmode'       => $uploadmode
		]);
		
		return $this->view->fetch('index');
	}
}
